﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>任务列表</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="/View_Mobile/Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm.min.css">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.8/css/sm-extend.min.css">

    <style type="text/css">
        .ms-controller, [ms-controller] {
            display: none;
        }
        .card-header {
            font-size:13px;
        }
        .card-content {
            font-size: 13px;
        }
        .card-footer {
            font-size: 13px;
        }
        .layermbtn span:first-child {
            background-color: rgba(255, 255, 255, 0) !important;
        }
        .ui-form-item label{width:105px;}
        .ui-form-item .wspan {
            width: 100%;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 105px;
        }
        
        .span {
            line-height: 1.5 !important;
            padding-bottom: 10px;
            overflow: hidden;
            word-wrap: break-word;
            margin:0;
        }
        .txtaa {
            margin-top: 10px;
            line-height: 1.5 !important;
            height: 100px;
        }
    </style>
</head>
<body ms-controller="XXList">
    <div class="page page-current" id="pageindex1">
        <div id="content">
            <div class="content-block " style=" margin: 0.5rem 0;">
                <div class="buttons-row ">
                    <!--<a href="UI_RWGL_LIST.html?Type=0" class="tablink active button external" style="height: 1.5rem; line-height: 1.5rem; " ms-if="mybd" ms-css-border-radius="mysh?'.25rem 0 0 .25rem':'.25rem'">待办任务</a>
                    <a href="UI_RWGL_LIST.html?Type=1" class="tablink button external" style="height: 1.5rem; line-height: 1.5rem; " ms-if="mysh">任务评价</a>-->
                    <a href="UI_RWGL_LIST.html?Type=0" class="tablink active button external" style="height: 1.5rem; line-height: 1.5rem; " >待办任务</a>
                    <a href="UI_RWGL_LIST.html?Type=1" class="tablink button external" style="height: 1.5rem; line-height: 1.5rem; " >任务评价</a>
                </div>
            </div>
            <div class="content infinite-scroll infinite-scroll-bottom" data-distance="50" style="margin-top: 2rem; ">
                <div class="list-container">
                    <div class="card" data-repeat-rendered="LoadScore" ms-repeat-el="ctData" ms-if="type=='0'">
                        <div class="ui-form ui-border-t">
                            <div class=" ui-border-b" style="height: auto;  padding: 10px; ">
                                <span class="span">【{{el.TypeName}}】{{el.RWTitle}}</span>
                            </div>
                            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                                <label>
                                    任务内容
                                </label>
                                <span class="wspan "></span>
                                <p class="span" ms-if="el.RWContent" ms-html="el.RWContent"></p>
                                <div style="clear: both"></div>
                            </div>
                            <div class="ui-form-item ui-border-b">
                                <label>
                                    督办人
                                </label>
                                <span class="wspan">{{ComFunJS.convuser(el.RWDBR)}}</span>
                            </div>
                            <div class="ui-form-item ui-border-b">
                                <label>
                                    负责人
                                </label>
                                <span class="wspan">{{ComFunJS.convuser(el.RWUSER)}}</span>
                            </div>
                            <div class="ui-form-item ui-border-b">
                                <label style="font-size:15px">
                                    要求完成时间
                                </label>
                                <span class="wspan">{{el.RWEDate|date("yyyy-MM-dd")}}</span>
                            </div>
                            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                                <label>
                                    完成情况
                                </label>
                                <div ms-if="el.RWUSER==nowuser&&el.Status==0">
                                    <textarea placeholder="请输入完成情况" ms-duplex="el.RWWCQK" class="txtaa"></textarea>
                                    <a id="wc" class="ui-btn-lg ui-btn-primary" ms-click="addwc(el)" style="float: right; width: auto; height: 30px; line-height: 30px; margin-top: -10px; margin-bottom:10px; margin-left: 5px;">完成</a>
                                    <div style="clear: both"></div>
                                </div>
                                <div ms-if="el.RWUSER!=nowuser||el.Status!=0">
                                    <span class="wspan "></span>
                                    <p class="span" ms-if="el.RWWCQK" ms-html="el.RWWCQK"></p>
                                    <div style="clear: both"></div>
                                </div>
                            </div>
                            <div class="ui-form-item ui-border-b" ms-if="el.Status>0">
                                <label>
                                    评分
                                </label>
                                <span class="wspan" ms-if="el.SHUser!=nowuser||el.Status==2">
                                    {{pf(el.RWFS)|html}} {{el.RWFS}}
                                </span>
                                <span class="wspan" ms-if="el.SHUser==nowuser&&el.Status!=2">
                                    <!--{{szpf(el)|html}}-->
                                    <span class="raty" ms-attr-score="el.RWFS" ms-attr-itemid="{{el.ID}}">
                                    </span>
                                </span>
                            </div>
                            <div class="ui-form-item ui-border-b" ms-if="el.Status>0" style="height:auto;min-height:44px">
                                <label>
                                    评价
                                </label>
                                <div ms-if="el.SHUser==nowuser&&el.Status!=2">
                                    <textarea placeholder="请输入评价" ms-duplex="el.DBPJ" class="txtaa"></textarea>
                                    <a id="pj" class="ui-btn-lg ui-btn-primary" ms-click="addpj(el)" style="float: right; width: auto; height: 30px; line-height: 30px; margin-top: -10px; margin-bottom:10px; margin-left: 5px;">评价</a>
                                    <div style="clear: both"></div>
                                </div>
                                <div ms-if="el.SHUser!=nowuser||el.Status==2">
                                    <span class="wspan "></span>
                                    <p class="span" ms-if="el.DBPJ" ms-html="el.DBPJ"></p>
                                    <div style="clear: both"></div>
                                </div>
                            </div>
                            <div class="ui-form-item ui-border-b ui-form-item-checkbox">
                                <label>
                                    任务状态
                                </label>
                                <span class="wspan" style="display:block;">
                                    {{rwzt(el.Status)|html}}
                                    <!--<label class="ui-checkbox" style="float:right;" ms-if="el.RWDBR==nowuser&&el.Status!=2">
                                <input type="checkbox" ms-attr-itemid="{{el.ID}}">
                            </label>-->
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="card" ms-repeat-el="ctData" ms-if="type=='1'" ms-on-tap="vieww(el)">
                        <div class="ui-form ui-border-t">
                            <div class="ui-form-item ui-border-b">
                                <label>
                                    任务编号
                                </label>
                                <span class="wspan">{{el.GroupCode}}</span>

                            </div>
                            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                                <label>
                                    任务标题
                                </label>
                                <span class="wspan "></span>
                                <p class="span" ms-if="el.GroupTitle" ms-html="el.GroupTitle"></p>
                                <div style="clear: both"></div>
                            </div>
                            <div class="ui-form-item ui-border-b">
                                <label>
                                    提交人
                                </label>
                                <span class="wspan">{{ComFunJS.convuser(el.CRUser)}}</span>
                            </div>
                            <div class="ui-form-item ui-border-b">
                                <label style="font-size:15px">
                                    完成情况
                                </label>
                                <span class="wspan">{{el.DBcount}}</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="infinite-scroll-preloader">
                    <div class="preloader"></div>
                </div>
            </div>
            <!--<div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
                <button class="ui-btn ui-btn-primary" ms-click="addrw()">
                    发布任务
                </button>
                <button class="ui-btn ui-btn-danger" ms-click="rwch()">
                    撤回
                </button>
                <button class="ui-btn ui-btn-primary" ms-click="rwss()">
                    送审
                </button>
                <button class="ui-btn " ms-click="rwgd()">
                    归档
                </button>
            </div>-->
            <!--<nav class="bar bar-tab">
                <div class="content-block" style="margin:0px;">
                    <div class="row">
                        <div class="col-33"><a href="javascript:void(0);" style="top:0px;" ms-click="addrw()" class="button button-big button-fill button-success external">发布任务</a></div>
                        <div class="col-33"><a href="javascript:void(0);" style="top:0px;" ms-click="addrw()" class="button button-big button-fill button-success external">送审</a></div>
                        <div class="col-33"><a href="javascript:void(0);" style="top:0px;" ms-click="addrw()" class="button button-big button-fill button-success external">撤回</a></div>
                    </div>
                </div>
            </nav>-->
        </div>
        <iframe id="iframep" src="" style="display: none; margin-bottom: -7px;" frameborder="0"></iframe>
    </div>
    <script src="/View_Mobile/JS/layer/layer.m.js"></script>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm-extend.min.js' charset='utf-8'></script>
    <script src="/View_Mobile/JS/avalon.mobile.min.js"></script>
    <script src="/View_Mobile/JS/ComFunJS.js?jsver=20160425"></script>
    <script src="/View_Mobile/JS/raty/jquery.raty.js?v=1.3"></script>
    <script>

        window.localStorage.removeItem("page");
        window.localStorage.setItem("page", 1);

        window.localStorage.removeItem("isjz");
        window.localStorage.setItem("isjz", 0);

        var height = 0;
        var width = 0;

        var model = avalon.define({
            $id: "XXList",
            ctData: [],
            tjel: "",
            ids: "",
            mysh: "",
            mybd: "",
            type: ComFunJS.getQueryString("Type"),
            nowuser: ComFunJS.getCookie("wxusername"),
            repshow: function () {
                $(this).parent().siblings().removeClass("active");
                $(this).parent().addClass("active");
            },
            vieww: function (el) {
                window.location = "/View_Mobile/UI/CUSTOM/UI_RWGL_PJLIST.html?id=" + el.GroupCode + "&type=1&r=" + Math.random();
            },
            addrw: function () {
                window.location = "UI_RWGL_INPUT.html?r="+Math.random();
            },
            addwc: function (wcel) {
                $.showIndicator()
                $.post("/API/VIEWAPI.ashx?Action=DBRW_SETCUS_SWRWGLWCQK&r=" + Math.random(), { P1: wcel.RWWCQK, P2: wcel.ID }, function (data) {
                    $.hideIndicator()
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $.toast("操作成功");
                    } else {

                        $.toast("操作失败");
                    }
                })
                //ComFunJS.showBJK("200", wcel.RWWCQK, "完成情况", function (nr) {

                //    $.showIndicator()
                //    $.post("/API/VIEWAPI.ashx?Action=SETCUS_SWRWGLWCQK&r=" + Math.random(), { P1: nr, P2: wcel.ID }, function (data) {
                //        $.hideIndicator()
                //        var data = $.parseJSON(data);
                //        if (data.ErrorMsg == "") {
                //            wcel.RWWCQK = nr;

                //            $.toast("操作成功");
                //        } else {

                //            $.toast("操作失败");
                //        }
                //    })

                //})
            },
            addss: function (ssel) {
                //var tc = layer.open({
                //    content: '确定要送审此任务吗？',
                //    btn: ['确定', '取消'],
                //    shadeClose: false,
                //    yes: function () {
                //        layer.close(tc);
                //        model.tjel = ssel;
                //        $("#content").hide();
                //        $("#iframep").show();

                //        var cheight = height;
                //        var cwidth = width;

                //        $("#iframep").css("height", cheight);
                //        $("#iframep").css("width", cwidth);
                //    }, no: function () {
                //    }
                //})
                model.tjel = ssel;
                $("#content").hide();
                $("#iframep").show();

                var cheight = height;
                var cwidth = width;

                $("#iframep").css("height", cheight);
                $("#iframep").css("width", cwidth);
            },
            addch: function (chel) {
                var tc = layer.open({
                    content: '确定要撤回此任务吗？',
                    btn: ['确定', '取消'],
                    shadeClose: false,
                    yes: function () {
                        layer.close(tc);
                        $.showIndicator();
                        $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_DELCUS_SWRWGLITEM', { P1: chel.ID }, function (resultData) {
                            $.hideIndicator();
                            if (resultData.ErrorMsg == "") {
                                model.ctData.remove(chel);
                                $.toast("操作成功");
                            }
                            else {
                                $.toast("操作失败");
                            }
                        })
                    }, no: function () {
                    }
                })
            },
            addgd: function (gdel) {
                var tc = layer.open({
                    content: '确定要归档此任务吗？',
                    btn: ['确定', '取消'],
                    shadeClose: false,
                    yes: function () {
                        layer.close(tc);
                        $.showIndicator();
                        $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_CUS_SWRWGLGD', { P1: gdel.ID }, function (resultData) {
                            $.hideIndicator();
                            if (resultData.ErrorMsg == "") {
                                gdel.Status = 2;
                                $.toast("操作成功");
                            }
                            else {
                                $.toast("操作失败");
                            }
                        })
                    }, no: function () {
                    }
                })
            },
            addpj: function (pjel) {
                $.showIndicator();
                $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_SETCUS_SWRWGLPJWCQK_WX&r=' + Math.random(), { "P1": pjel.DBPJ, ID: pjel.ID }, function (resultData) {
                    $.hideIndicator();
                    if (resultData.ErrorMsg == "") {
                        $.toast("操作成功");
                    }
                    else {
                        $.toast("操作失败");
                    }
                })

                //ComFunJS.showPFBJK("200", pjel.DBPJ, pjel.RWFS, "评价意见", function (nr, pc) {
                //    $.showIndicator();
                //    $.getJSON('/API/VIEWAPI.ashx?Action=SETCUS_SWRWGLPJWCQK&r=' + Math.random(), { "P1": nr, "P2": pc, ID: pjel.ID }, function (resultData) {
                //        $.hideIndicator();
                //        if (resultData.ErrorMsg == "") {
                //            pjel.DBPJ = nr;
                //            pjel.RWFS = pc;
                //            $.toast("操作成功");
                //        }
                //        else {
                //            $.toast("操作失败");
                //        }
                //    })

                //})
            },
            LoadScore: function (type) {
                if (type == "add" && $(".raty").length > 0) {
                    $(".raty").raty({
                        //readOnly: true,
                        //cancel: true,
                        score: function () {
                            return $(this).attr("score") * 1 / 20;
                        },
                        click: function (score, evt) {
                            $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_SETCUS_SWRWGLPFWCQK_WX&r=' + Math.random(), { "P1": score * 20, ID: $(this).attr("itemid") }, function (resultData) {
                                if (resultData.ErrorMsg == "") {
                                    $.toast("操作成功");
                                }
                                else {
                                    $.toast("操作失败");
                                }
                            })
                        }
                    });
                }
            },
            xzrw: function () {
                var html = '';
                $("input[type=checkbox]:checked").each(function (index, obj) {
                    var xzid=$(obj).attr("itemid");
                    if (html) {
                        html = html + ',' + xzid;
                    }
                    else {
                        html =  xzid;
                    }
                })
                if (html) {
                    model.ids = html;
                }
                else {
                    $.toast("请选择任务");
                }
            },
            rwch: function () {
                model.xzrw();
                if (model.ids) {
                    var tc = layer.open({
                        content: '确定要撤回这些任务吗？',
                        btn: ['确定', '取消'],
                        shadeClose: false,
                        yes: function () {
                            layer.close(tc);
                            $.showIndicator();
                            $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_DELCUS_SWRWGLITEM', { P1: model.ids }, function (resultData) {
                                $.hideIndicator();
                                if (resultData.ErrorMsg == "") {
                                    $(model.ids.split(',')).each(function (index, obj) {
                                        $(model.ctData).each(function (inx, ele) {
                                            if (ele.ID == obj) {
                                                model.ctData.remove(ele);
                                            }
                                        })
                                    })

                                    $.toast("操作成功");
                                }
                                else {
                                    $.toast("操作失败");
                                }
                            })
                        }, no: function () {
                        }
                    })
                }
            },
            rwss: function () {
                model.xzrw();
                if (model.ids) {
                    $("#content").hide();
                    $("#iframep").show();

                    var cheight = height;
                    var cwidth = width;

                    $("#iframep").css("height", cheight);
                    $("#iframep").css("width", cwidth);
                }
            },
            rwgd: function () {
                model.xzrw();
                if (model.ids) {
                    var tc = layer.open({
                        content: '确定要归档这些任务吗？',
                        btn: ['确定', '取消'],
                        shadeClose: false,
                        yes: function () {
                            layer.close(tc);
                            $.showIndicator();
                            $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_CUS_SWRWGLGD', { P1: model.ids }, function (resultData) {
                                $.hideIndicator();
                                if (resultData.ErrorMsg == "") {
                                    $(model.ids.split(',')).each(function (index, obj) {
                                        $(model.ctData).each(function (inx, ele) {
                                            if (ele.ID == obj) {
                                                ele.Status = 2;
                                            }
                                        })
                                    })
                                    $.toast("操作成功");
                                }
                                else {
                                    $.toast("操作失败");
                                }
                            })
                        }, no: function () {
                        }
                    })
                }
            },
            action: function () {
                if (model.type) {
                    if (model.type == "0") {
                        return "DBRW_GETCUS_SWRWGLDBLIST&status=0";
                    }
                    else if (model.type == "1") {
                        return "DBRW_GETCUS_SWRWGLDSHLIST";
                    }
                }
                else {
                    return "DBRW_GETCUS_SWRWGLDBLIST&status=0";
                }
            }
        })

        function loadMore() {
            var isjz = window.localStorage.getItem("isjz");
            if (isjz == 0) {
                window.localStorage.setItem("isjz", 1);
                var page = window.localStorage.getItem("page");

                if (page != "0") {
                    $.getJSON("/API/VIEWAPI.ashx?Action=" + model.action() + "&r=" + Math.random(), { "p": page }, function (r) {

                        if (r.ErrorMsg == "") {
                            if (r.Result.length > 0) {
                                model.ctData.pushArray(r.Result);
                                if (r.Result.length < 8) {
                                    window.localStorage.setItem("page", 0);

                                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                                    $.detachInfiniteScroll($('.infinite-scroll'));
                                    // 删除加载提示符
                                    $('.infinite-scroll-preloader').remove();
                                }
                                else {
                                    var page = window.localStorage.getItem("page");
                                    window.localStorage.setItem("page", parseInt(page) + 1);
                                }
                            } else {
                                var page = window.localStorage.getItem("page");
                                if (page == "1") {
                                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                                    $.detachInfiniteScroll($('.infinite-scroll'));
                                    // 删除加载提示符
                                    $('.infinite-scroll-preloader').remove();
                                }
                                else {
                                    window.localStorage.setItem("page", 0);

                                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                                    $.detachInfiniteScroll($('.infinite-scroll'));
                                    // 删除加载提示符
                                    $('.infinite-scroll-preloader').remove();
                                }
                            }
                            $.refreshScroller();
                        } else {

                        }
                        window.localStorage.setItem("isjz", 0);
                    })
                }
            }
        }

        avalon.ready(function () {
            if (!model.type) {
                model.type = "0";
            }
            height = document.documentElement.clientHeight;
            width = document.documentElement.clientWidth;

            $("#iframep").attr("src", "/View_Mobile/UI/UI_PERSON.html?r=" + Math.random() + "&Type=1");

            //$.getJSON("/API/VIEWAPI.ashx?Action=GETCUS_SWRWGLDSHLIST&r=" + Math.random(), { "p": 1 }, function (r) {

            //    if (r.ErrorMsg == "") {
            //        if (r.Result.length > 0) {
            //            model.mysh = "1";
            //            model.mybd = "1";
            //        }
            //        else {
            //            model.mybd = "1";
            //        }
            //    }
            //    if (model.type == "0") {
            //        $(".buttons-row a").removeClass("active");
            //        $(".buttons-row a").eq(0).addClass("active");
            //    }
            //    else if (model.type == "1") {
            //        $(".buttons-row a").removeClass("active");
            //        $(".buttons-row a").eq(1).addClass("active");
            //    }
            //})
            if (model.type == "0") {
                $(".buttons-row a").removeClass("active");
                $(".buttons-row a").eq(0).addClass("active");
            }
            else if (model.type == "1") {
                $(".buttons-row a").removeClass("active");
                $(".buttons-row a").eq(1).addClass("active");
            }
            // 注册'infinite'事件处理函数
            $(document).on('infinite', '.infinite-scroll-bottom', function () {
                loadMore();
            });

            $.init();
            loadMore();

        })

        function goback() {
            $("#content").show();
            $("#iframep").hide();
        }
        function goconfirm(json) {
            if (json != null) {
                $.showIndicator();
                model.ctData.HDPeople = json.vusername;
                $.getJSON('/API/VIEWAPI.ashx?Action=DBRW_SENDCUS_SWRWGLWCQK&r=' + Math.random(), { P1: json.vusername, P2: model.ids }, function (resultData) {
                    $.hideIndicator();
                    if (resultData.ErrorMsg == "") {
                        $(model.ids.split(',')).each(function (index, obj) {
                            $(model.ctData).each(function (inx, ele) {
                                if (ele.ID == obj)
                                {
                                    ele.Status = 1;
                                    ele.SHUser = json.vusername;
                                }
                            })
                        })
                        
                        $.toast("操作成功");
                    }
                    else {
                        $.toast("操作失败");
                    }
                })
            }
            else {
                $.toast("请选择评价人");
            }

            $("#content").show();
            $("#iframep").hide();
        }
        function rwzt(strsp) {
            if (strsp == 0) {
                return '<span class="badge" style="background-color:red;color:white;">新任务</span>';
            }
            else if (strsp == 1) {
                return '<span class="badge" style="background-color:blue;color:white;">已送审</span>';
            }
            else if (strsp == 2) {
                return '<span class="badge" >已归档</span>';
            }
        }
        function pf(str) {
            if (str) {
                var html = '<div></div>';
                var html1=$(html).raty({
                    readOnly: true,
                    score: str * 1 / 20
                }).html();
                return html1;
            }
            else {
                return '';
            }
        }
    </script>

</body>



</html>
